Object.defineProperty(exports, "__esModule", {
  value: !0
});

var o = require("./config.js").config;

exports.request = function (e) {
  var t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : "common",
      n = arguments.length > 2 && void 0 !== arguments[2] && arguments[2],
      i = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : "host";
  n && uni.showLoading({
    title: "加载中",
    icon: "looading"
  });
  var r = "";
  var contentType = "application/x-www-form-urlencoded";
  if ("dict" === t) {
	  e.method = 'get';
  }
  if ("normal" === t) {
	  contentType = "application/json";
	  if (e.data.contentType) {
		  contentType = e.data.contentType;
	  }
  }
	
  var header = {
		"Content-Type": contentType,
	};
	// if (e.token) {
	// 	header['Authorization'] = "Bearer " + e.token;
	// }
  return "host" === i ? (r = o.host, "dict" === t ? r += "/app/dict" : "normal" === t ? r += e.data.api : "common" !== t ? r = r + e.url + "?app_id=h5" : r += "/common/api-public?app_id=h5") : "other" === i ? r = o.other + "/comm/currency.do" : "app" === i && (r = o.apphost + e.url + "?app_id=h5"), new Promise(function (o, t) {
	uni.request({
      url: r,
      data: e.data,
      header: header,
      method: e.method || "POST",
      dataType: "json",
      success: function (e) {
        o(e);
      },
      error: function (o) {
        t(o), uni.showToast({
          title: "系统繁忙，请稍后再试",
          icon: "success"
        });
      },
      complete: function () {
        n && setTimeout(function () {
          uni.hideLoading();
        }, 200);
      }
    });
  });
};